<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){	
	if(!$_RQ['id']){
		exi('请选择课程！','error');
	}
	$return['params']=array('video_id'=>$_RQ['id'],'merchid'=>$_SESSION['onemerchid'],'keyword'=>'');
	if($_RQ['keyword']){
		$return['params']['keyword']=$_RQ['keyword'];
	}
	$return['video']=pdo_get('jy_xiaoeknow_video',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	$return['jies']=array();
	$return['sharedata']=array(
		'title'=>$return['video']['title'].'的章节',
		'desc'=>$return['video']['desc'],
		'link'=>custom_url('jy_xiaoeknow/video_jie//id='.$_RQ['id'],true),
		'imgUrl'=>tomedia($return['video']['thumb']),
	);
	set_html('title',$return['video']['title'].'的章节');
	exi($return);
}
if($_RQ['op']=='getlist'){	
	if(!$_RQ['video_id']){
		exi('请选择课程！','error');
	}
	$params=array('video_id'=>$_RQ['video_id'],'uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid'],'status'=>1);
	if($_RQ['keyword']){
		$params['keyword']=$_RQ['keyword'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 8;
	$list=pdo_getslice('jy_xiaoeknow_video_jie',$params,array($pindex,$psize),$total,$fields,'','paixu desc');
	foreach($list as $k=>&$item){
		$item['jieitems']=pdo_getall('jy_xiaoeknow_video_jieitem',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'merchid'=>$_SESSION['onemerchid'],'jie_id'=>$item['id'],'xuanxiu'=>0),array(),'','paixu desc');
		if(!count($item['jieitems'])){
			unset($list[$k]);
		}
		$item['thumb']=tomedia($item['thumb']);
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='getlist2'){	
	if(!$_RQ['video_id']){
		exi('请选择课程！','error');
	}
	$params=array('video_id'=>$_RQ['video_id'],'uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid'],'status'=>1);
	if($_RQ['keyword']){
		$params['keyword']=$_RQ['keyword'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 8;
	$list=pdo_getslice('jy_xiaoeknow_video_jie',$params,array($pindex,$psize),$total,$fields,'','paixu desc');
	foreach($list as $k=>&$item){
		$item['jieitems']=pdo_getall('jy_xiaoeknow_video_jieitem',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'merchid'=>$_SESSION['onemerchid'],'jie_id'=>$item['id'],'xuanxiu'=>1),array(),'','paixu desc');
		if(!count($item['jieitems'])){
			unset($list[$k]);
		}
		$item['thumb']=tomedia($item['thumb']);
	}
	$return['list']=$list;
	exi($return);
}
